import 'package:cbec_app/components/base/base_chekbox.dart';
import 'package:cbec_app/components/base/base_image.dart';
import 'package:cbec_app/components/base/base_interactive.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/pages/login/controller/phone_bind_ctr.dart';
import 'package:cbec_app/pages/my/controller/statement_ctr.dart';
import 'package:cbec_app/routes/routes.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

///微信绑定电话号码页面
class PhoneBindWeachat extends GetView<PhoneBindController>{
  const PhoneBindWeachat({super.key});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<PhoneBindController>(builder: (controller){
      return BasePage(
      bodyColor: Colors.white,
      iconType: IconType.back,
      navType: NavType.common,
      children: [
        Container(
          margin: EdgeInsets.only(top: 155.w),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              BaseImage(url: "login_wechat.png", width: 54.w,height: 54.w),
              SizedBox(width: 8.w),
              BaseImage(url: "link.png", width: 24.w,height: 24.w),
              SizedBox(width: 8.w),
              BaseImage(url: "login_logo.png", width: 54.w,height: 54.w),
            ],
          ),
        ),
        Container(
          margin: EdgeInsets.only(top: 10.w),
          alignment: Alignment.center,
          child: Text("绑定微信后可使用微信账号或者手机登录百大易购",style: setTextStyle(12, FontWeight.normal, Tools.fromHex("#333333"))),
        ),

        Container(
          margin: EdgeInsets.fromLTRB(18.w, 20.w, 18.w, 0.w),
          // color: Colors.red,
          child: Column(
            children: [
              //手机号输入框
              Container(
                height: 44.h,
                // margin: EdgeInsets.only(top: 20.w),
                padding: EdgeInsets.only(top: 12.w, left: 16.w, right: 16.w),
                decoration:
                    border_radis(Tools.fromHex("#F3F5F7"), radiusValue: 50),
                child: TextFormField(
                  maxLength: 11,
                  onChanged: controller.onInputPhone,
                  decoration: descript("手机号"),
                ),
              ),
              //密码输入框
              Container(
                  height: 44.h,
                  margin: EdgeInsets.only(top: 20.w),
                  padding: EdgeInsets.only(left: 16.w, right: 16.w),
                  decoration:
                      border_radis(Tools.fromHex("#F3F5F7"), radiusValue: 50),
                  child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          SizedBox(
                            width: 200.w,
                            child: TextFormField(
                              onChanged: controller.onInputCode,
                              decoration: descript("请输入验证码"),
                              // obscureText: controller.hidePassword,
                            ),
                          ),
                          //获取验证码
                          BaseInteractive(
                            onClick: () {
                              controller.sendCode();
                            },
                            childWidget: Text(controller.countdownTxt,style: setTextStyle(13, FontWeight.normal, Tools.fromHex("#4D87FF"))),
                          )
                        ],
                      )),

                      authBox(),

                      solidButton("完成绑定",fontsize: 13, height: 40.w,radius: 30.w,() {
                        controller.completeBind();
                      })


            ],
          ),
        )

      ],
    );
    });
  }




  //同意协议组件
  Widget authBox() {
    return Container(
      margin: EdgeInsets.only(top: 20.w,bottom: 40.w),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          BaseCheckBox(
              value: controller.isAgree,
              onChange: (selected) {
                controller.isAgree = selected;
              },
            ),
          SizedBox(width: 5.w),
          SizedBox(
              width: 300.w,
              child: RichText(
                text: TextSpan(
                  style: TextStyle(
                      fontSize: 12.0,
                      color: Tools.fromHex("#999999"),
                      fontWeight: FontWeight.w300),
                  children:  [
                    const  TextSpan(text: '我已阅读并同意'),
                    TextSpan(
                      recognizer: TapGestureRecognizer()..onTap =() {
                        Get.toNamed(Routes.statement,arguments: RichTextLinkType.privacyPolicy);
                      },
                      text: '《隐私政策》',
                      style: const TextStyle(
                        fontWeight: FontWeight.bold,
                        color: Colors.blue,
                      ),
                    ),
                    const TextSpan(text: '和'),
                    TextSpan(
                      text: '《用户服务协议》',
                      recognizer: TapGestureRecognizer()..onTap =() {
                        Get.toNamed(Routes.statement,arguments: {"title":"注册协议"});
                      },
                      style: const TextStyle(
                        fontWeight: FontWeight.bold,
                        color: Colors.blue,
                      ),
                    ),
                  ],
                ),
              ))
        ],
      ),
    );
  }
}